/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.ingsoc2;

import java.awt.event.ActionListener;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
import javax.swing.table.DefaultTableModel;

public class VcPrincipalViewMock implements VcPrincipalView {

    private javax.swing.JButton cmdEliminar;
    private javax.swing.JButton cmdExportar;
    private javax.swing.JButton cmdFiltrar;
    private javax.swing.JButton cmdNuevo;
    private javax.swing.JComboBox comboGenero;

    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField txtDirector;
    private javax.swing.JTextField txtTitulo;

    public VcPrincipalViewMock() {
        initComponents();

    }

    @Override
    public void mostrarPantalla() {

    }

    public String getTxtGenero() {
        return "";
    }

    public String getTxtTitulo() {
        return this.txtTitulo.getText();
    }

    public String getTxtDirector() {
        return this.txtDirector.getText();

    }

    public void cerrar() {

    }

    @Override
    public void mostrarResultado(List<Pelicula> resultado) {
        DefaultTableModel tm = new DefaultTableModel();
        jTable1.setModel(tm);
        jTable1.setAutoCreateRowSorter(true);
        tm.addColumn("ID");
        tm.addColumn("Titulo");
        tm.addColumn("Director");
        tm.addColumn("Duracion");
        for (Pelicula pp : resultado) {
            Object[] objs
                    = {
                        pp.getId(), pp.getTitulo(), pp.getDirector(), pp.getDuracion()
                    };

            tm.addRow(objs);
        }
    }

    public void agregarListenerCmdEliminar(ActionListener lst) {
        cmdEliminar.addActionListener(lst);
    }

    public void agregarListenerCmdExportar(ActionListener lst) {
        cmdExportar.addActionListener(lst);
    }

    public void agregarListenerCmdFiltrar(ActionListener lst) {
        cmdFiltrar.addActionListener(lst);
    }

    public void agregarListenerCmdNuevo(ActionListener lst) {
        cmdNuevo.addActionListener(lst);
    }

    @Override
    public ArrayList getSelectedPeliculaID() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    private void initComponents() {
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        txtTitulo = new javax.swing.JTextField();
        txtDirector = new javax.swing.JTextField();
        comboGenero = new javax.swing.JComboBox();
        cmdFiltrar = new javax.swing.JButton();
        cmdNuevo = new javax.swing.JButton();
        cmdEliminar = new javax.swing.JButton();
        cmdExportar = new javax.swing.JButton();
    }

    @Override
    public void cargarGenero(Collection<Genero> listarGenero) {
        final DefaultComboBoxModel model = new DefaultComboBoxModel();
        model.addElement(new Genero(-1));
        for (Genero miGenero : listarGenero) {

            model.addElement(miGenero);
        }

        comboGenero.setModel(model);
    }

    @Override
    public Genero getSelectedGenero() {
        return (Genero) comboGenero.getSelectedItem();

    }

    @Override
    public void agregarListenerEditar(MouseListener lst) {
        jTable1.addMouseListener(lst);
    }

}
